#include "DL_EH.h"
#include "My_PARAM.h"
#include "Data_Buffer.h"
#include "DL_MH.h"
#include <string.h>
EH_STATE_TYPE EH_STATE;

 


 EventMemory_TYPE EventMemory;

void Init_EH(void){
    EH_STATE=EH_Inactive_0;
    
}

//转移动作函数声明


void DL_EH_T4_6(void);

void DL_EH_T5(void);



//事件函数

void Event_EH_Conf_ACTIVE(void){
    if(EH_STATE==EH_Inactive_0){
        EH_STATE=EH_Idle_1;
        //DL_EH_T1();
    }
}

void Event_EH_Conf_INACTIVE(void){
    if(EH_STATE==EH_Idle_1||EH_STATE==EH_FreezeEventMemory_2){
        EH_STATE=EH_Inactive_0;
        //DL_EH_T7();
    }
}

void Event_EventRead(void){
    if(EH_STATE==EH_FreezeEventMemory_2||EH_STATE==EH_Idle_1){
        DL_EH_T4_6();
    }
}

//任何对EventMemory写操作都会触发
void Event_EventConf(void){
    if(EH_STATE==EH_FreezeEventMemory_2){
        EH_STATE=EH_Idle_1;
        DL_EH_T5();
    }
    
}


void DL_EH_T4_6(void){
    uint8_t EventMemAddr=(*MC_STRUCT.MC)&0x1F;//提取EventMem地址
    memset(MC_STRUCT.OD,0,MC_STRUCT.OD_Len);//OD清零
    *MC_STRUCT.OD=EventMemory.Data[EventMemAddr]; //OD填充数据
                   
	Event_MH_Ready();
}


void DL_EH_T5(void){
     *MC_STRUCT.CKS=*MC_STRUCT.CKS&0x7F ; //EventFlag位清零
     memset(EventMemory.Data,0,19);  //

}

 



